package com.manpower.ui;

import java.util.ArrayList;
import java.util.HashMap;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.GridView;
import android.widget.SimpleAdapter;

public class ReportUserGridActivity extends BaseActivity {

	private GridView grdView;
	private final String GRIDVIEW_ITEM_TITLE = "title";
	private final String GRIDVIEW_ITEM_DESC = "desc";

	private final String[] gridview_item_descript = new String[] { "未报户", "已报户" };
	private final Object[] gridview_item_pic = new Object[] {
			R.drawable.un_commit_style,
			R.drawable.have_commit_style };
	private ArrayList<HashMap<String, Object>> arrList = new ArrayList<HashMap<String, Object>>();
	private SimpleAdapter adapter;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_reportusergrid);
		txtTitle.setText(R.string.label_EnRegistration);

		grdView = (GridView) this.findViewById(R.id.grdList);
		for (int i = 0; i < gridview_item_descript.length; i++) {
			HashMap<String, Object> hashMap = new HashMap<String, Object>();
			hashMap.put(GRIDVIEW_ITEM_TITLE, gridview_item_pic[i]);
			hashMap.put(GRIDVIEW_ITEM_DESC, gridview_item_descript[i]);
			arrList.add(hashMap);
		}
		adapter = new SimpleAdapter(this, arrList,
				R.layout.reportusergridview_item, new String[] {
						GRIDVIEW_ITEM_TITLE, GRIDVIEW_ITEM_DESC }, new int[] {
						R.id.imgPic, R.id.txtDescript });
		grdView.setAdapter(adapter);
		grdView.setOnItemClickListener(onItemClickGridView);
	}
	
	private OnItemClickListener onItemClickGridView=new OnItemClickListener() {

		@Override
		public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
				long arg3) {
//			startActivity(new Intent(ReportUserGridActivity.this, ReportUserActivity.class));
//			ReportUserGridActivity.this.finish();
			/*
			 * to send the test param mUserType
			 */
			Intent intent = new Intent(ReportUserGridActivity.this, ReportUserActivity.class);
			intent.putExtra("userType", arg2);
			startActivity(intent);
			ReportUserGridActivity.this.finish();
		}
	};
}
